package reduce.fz.com.reduce.fragment;


import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import reduce.fz.com.reduce.R;
import reduce.fz.com.reduce.adapter.BaseRecycleViewHolder;
import reduce.fz.com.reduce.bean.StoryCard;
import reduce.fz.com.reduce.custom.view.RoundNetworkImageView;
import reduce.fz.com.reduce.fragment.base.BaseListFragment;
import reduce.fz.com.reduce.util.HttpUtils;
import reduce.fz.com.reduce.util.http.ImageLoader;

public class ShareExpListFragment extends BaseListFragment<ShareExpListFragment.MyShareViewHolder, StoryCard> {


    public ShareExpListFragment() {
    }

    @Override
    public MyShareViewHolder createItemViewHolder(ViewGroup parent) {
        View view = layoutInflater.inflate(R.layout.share_story_exp_item, parent, false);
        MyShareViewHolder holder = new MyShareViewHolder(view, new ShareExpListener() {
            @Override
            public void onItemClick() {

            }
        });
        return holder;
    }

    @Override
    public MyShareViewHolder createfootViewHolder(View view) {
        MyShareViewHolder holder = new MyShareViewHolder(view);
        return holder;
    }

    @Override
    public String createReqUrl() {
        return null;
    }


    public static class MyShareViewHolder extends BaseRecycleViewHolder<StoryCard> {
        //分享监听
        private ShareExpListener listener;
        //item图片
        private RoundNetworkImageView mIvShareItem;

        private TextView mStoryTitle;

        private TextView mTvBaseInfo;

        private RoundNetworkImageView mUserHeader;
        private TextView mTvUserNickname;
        public  ImageLoader mImageLoader= HttpUtils.getImageLoader();
        public void initWidget(View itemView) {
            mIvShareItem = (RoundNetworkImageView) itemView.findViewById(R.id.iv_share_item);
            mStoryTitle = (TextView) itemView.findViewById(R.id.story_title);
            mTvBaseInfo=(TextView)itemView.findViewById(R.id.tv_baseinfo);
            mUserHeader=(RoundNetworkImageView)itemView.findViewById(R.id.iv_user_header);
            mTvUserNickname=(TextView)itemView.findViewById(R.id.tv_user_nickname);
        }

        public MyShareViewHolder(View itemView) {
            super(itemView);
            initWidget(itemView);
        }

        public MyShareViewHolder(View itemView, ShareExpListener listener) {
            this(itemView);
            this.listener = listener;
        }

        @Override
        public void renderView(StoryCard data, int position) {
            mIvShareItem.setImageUrl(data.cardurl,mImageLoader);
            mStoryTitle.setText(data.title);
            mTvBaseInfo.setText(data.count_share+"");
            mUserHeader.setImageUrl(data.user.headurl,mImageLoader);
            mTvUserNickname.setText(data.user.nickname);

        }
    }

    public interface ShareExpListener {
        void onItemClick();
    }

}
